<?php 
	ob_start(); session_start(); 
	require_once('adminpanel/config/setting.php');
	
	function convertimedate($ndate,$ntime){
		$breakdate = explode('/',$ndate);
		$nmonth = $breakdate[0];
		$nday = $breakdate[1];
		$nyear = $breakdate[2];
		switch ($ntime) {
			case '11:00AM':$nhour = 11; break;
			case '1:00PM': $nhour = 13; break;
			case '3:00PM': $nhour = 15; break;
			case '5:00PM': $nhour = 17; break;
			case '7:00PM': $nhour = 19; break;
		}
		$ntimestamp = mktime($nhour, 0, 0, $nmonth, $nday, $nyear);
		return $ntimestamp;
	}

	
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registration</title>
</head>
<style>
	.topmenu{
		font-family:arial;
		font-size:14px;
		color:#FFFFFF;
		text-decoration:none;
	}
	.topmenu:hover{
		font-family:arial;
		font-size:14px;
		color:#FFFFFF;
		text-decoration:underline;
	}
</style>

<body style="margin:0px; background-color:#f1f1f1">
	<div id="header" style="background:url(images/top-bg.png) repeat-x; " align="center">
    	<div style="width:982px;" >
        	<div style="padding-top:30px; padding-right:20px; color:#FFFFFF" align="right">
            	<img src="images/the-century-logo.png" style="position:absolute; top:10px; margin-left:-450px;" />
            	<a href="index.php" class="topmenu">Home</a> &nbsp; | &nbsp; 
                <a href="about-us.php" class="topmenu">About Us</a> &nbsp; | &nbsp; 
                <a href="questions.php" class="topmenu">Questions</a> &nbsp; | &nbsp; 
                <a href="reservation.php" class="topmenu">Reservation</a> &nbsp; | &nbsp; 
                <a href="menu.php" class="topmenu">Menu</a> &nbsp; | &nbsp; <?php if(!($_SESSION['username'])){?>
                <a href="signup.php" class="topmenu">Signup</a><?php } else {?>
                <a href="logout.php" class="topmenu">Logout</a><?php }?>
                <br /><br/>
                <?php 
                include('login.php');
				?>
            </div>
        	<img src="images/top-gradient.png" />
            <div style="position:absolute; top:150px; margin-left:50px; font-size:24px; color:#F00 ">View My Reservation</div>
        </div>
    </div>
	<div id="body" align="center">
    	<div style="width:982px" align="center">
            <div style="width:900px;margin-left:0px; line-height:18px; font-family:verdana; font-size:12px; color:#666" align="left" >
                <table  bgcolor="#FFFFFF" style="width:700px; border:dotted 1px #FF0000; font-family:arial; font-size:12px" >
                    <tr>
                        <td bgcolor="#FF0000" style="color:#FFF" height="30px" align="center"><b>Reservation Date</b></td>
                        <td bgcolor="#FF0000" style="color:#FFF" height="30px" align="center"><b>Selected Table</b></td>
                        <td bgcolor="#FF0000" style="color:#FFF" height="30px" align="center"><b>Selected Time</b></td>
                        <td bgcolor="#FF0000" style="color:#FFF" height="30px" align="center"><b>Status</b></td>
                        <td bgcolor="#FF0000" style="color:#FFF" height="30px" align="center"><b>Action</b></td>
                    </tr>
                    
                    <?php
					$tmpid = $_SESSION['memberid'];
                            $result = mysql_query("select * from tbl_reservation where mid='$tmpid' order by id DESC ") or die (mysql_error());
                            while ($row = mysql_fetch_array($result)){
                                $id = $row['id']; 
                                $mid = $row['mid']; 
                                $selected_date = $row['selected_date']; 
                                $selected_table = $row['selected_table']; 
                                $selected_time = $row['selected_time']; 
                                $status = $row['status'];
                                if($status=='0'){
                                    $statdesc = 'Cancelled';	
                                }
                                if($status=='1'){
                                    $statdesc = 'Unconfirmed';	
                                }
                                if($status=='2'){
                                    $statdesc = 'Confirmed';	
                                }
								if(time()>convertimedate($selected_date,$selected_time)){
									if($status=='2'){
									  $statdesc = 'Completed';
									}
									if($status=='1'){
									  $statdesc = 'Cancelled';	
									}
								}
								if($statdesc<>'Cancelled'){
									echo '
										<tr >
											<td align="center" height="24px" style="border-bottom:dotted #666666 1px;">'.$selected_date.' </td>
											<td align="center" style="border-bottom:dotted #666666 1px;">Table '.$selected_table.'</td>
											<td align="center" style="border-bottom:dotted #666666 1px;">'.$selected_time.'</td>
											<td align="center" style="border-bottom:dotted #666666 1px;">'.$statdesc.'</td>
											<td align="center" style="border-bottom:dotted #666666 1px;"><a href="update-my-reservations.php?rid='.$id.'">Update</a></td>
										</tr>';
								}
                            }                
                        ?>                        
                </table>            
            </div>
        </div>
    </div>
    <div id="footer" style="background:url(images/btm-bg.png) repeat-x; height:166px" align="center">
    	<div style="width:982px">
        	<div style="height:40px"></div>
        	<img src="images/btm-gradient.png" />
        </div>
    		
    </div>
<script>
	function checkgender(g){
		var ngender = '';
		if(g==1){
			document.regform.gender.value = 'M';
		}
		if(g==2){
			document.regform.gender.value = 'F';
		}
	}
	
	function validateField(){
		var emptyfield = '', iChars = "!@#$%^&*()+=-[]\\\';,./{}|\":<>?";
		
		if(document.regform.firstname.value.trim()==''){
			emptyfield += ' > First Name \n';
		}
		if(document.regform.lastname.value.trim()==''){
			emptyfield += ' > Last Name \n';
		}
		if(document.regform.email.value.trim()==''){
			emptyfield += ' > Email Address \n';
		}
		if(document.regform.email.value != document.regform.confirmemail.value){
			emptyfield += ' > Email mismatch please re-enter again \n';
		}
		if(document.regform.gender.value.trim()==''){
			emptyfield += ' > Gender \n';
		}
		if(document.regform.nmonth.value =='' || document.regform.nday.value=='' || document.regform.nyear.value==''){
			emptyfield += ' > Birthday\n';
		}
		
		if(document.regform.password.value.trim()=='' ){
			emptyfield += ' > Password \n';
		}
		
		
		
	  for (var i = 0; i < document.regform.username.value.length; i++) {
		if (iChars.indexOf(document.regform.username.value.charAt(i)) != -1) {
		alert ("Your username has special characters. \nThese are not allowed.\n Please remove them and try again.");
		return false;
		}
	  }		
		
		if (document.regform.email.value.length > 0) {
		  i=document.regform.email.value.indexOf("@")
		  j=document.regform.email.value.indexOf(".",i)
		  k=document.regform.email.value.indexOf(",")
		  kk=document.regform.email.value.indexOf(" ")
		  jj=document.regform.email.value.lastIndexOf(".")+1
		  len=document.regform.email.value.length
		
		if ((i>0) && (j>(1+1)) && (k==-1) && (kk==-1) && (len-jj >=2) && (len-jj<=3)) {
		} else {
		  alert("Please enter correct email address.\n" +
		  document.regform.email.value + " is invalid.");
		  return false;
		  }
		}		
		
		if(emptyfield==''){
			return true;				
		}else{
			alert('Please complete required fields: \n'+emptyfield);
			return false;
		}
	}

</script>    
</body>
</html>